//
//  MainViewController.m
//  share_business
//
//  Created by 吴于凌 on 2017/8/26.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "MainViewController.h"
#import "BaseNavigationController.h"
#import "HomeViewController.h"
#import "MineViewController.h"
#import "ClassifyViewController.h"
#import "ShoppingCartViewController.h"
@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    HomeViewController *v1 = [[HomeViewController alloc]init];
    [self addTabBarChildVC:v1 title:@"首页" icon:@"home_tap" selecticon:@"home_tap_select1" ];
    
    ClassifyViewController *v2 = [[ClassifyViewController alloc]init];
    [self addTabBarChildVC:v2 title:@"分类" icon:@"classify_bottomicon" selecticon:@"classify_bottomicon2" ];
    
    ShoppingCartViewController *v3 = [[ShoppingCartViewController alloc]init];
    [self addTabBarChildVC:v3 title:@"购物车" icon:@"shoping_cart_icon2" selecticon:@"shoping_cart_icon" ];
    
    MineViewController *v4 = [[MineViewController alloc]init];
    [self addTabBarChildVC:v4 title:@"我的" icon:@"mine_bottomicon2" selecticon:@"mine_bottomicon" ];
    
    // 底部导航栏选中后的文字颜色
    self.tabBar.tintColor = [UIColor orangeColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (void) addTabBarChildVC:(UIViewController*)childVC title:(NSString *)title icon:(NSString *)icon selecticon:(NSString *)selectIcon{
    // 导航跟控制器
    BaseNavigationController *navController = [[BaseNavigationController alloc]initWithRootViewController:childVC];
    // 底部导航标题
    navController.tabBarItem.title = title;
 
    // 底部导航图标（默认）
    navController.tabBarItem.image = [[UIImage imageNamed:icon ]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 底部导航图标（点击）
    navController.tabBarItem.selectedImage =  [[UIImage imageNamed:selectIcon]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 将当前子控制器添加到底部导航控制器
    [self addChildViewController:navController];
}

@end
